home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / tutorials / custEducation / opengl2 / lib / debug.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  5.8 KB  |  192 lines

  1. /*
  2.  * Copyright 1993, 1994, Silicon Graphics, Inc.
  3.  * All Rights Reserved.
  4.  *
  5.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6.  * the contents of this file may not be disclosed to third parties, copied or
  7.  * duplicated in any form, in whole or in part, without the prior written
  8.  * permission of Silicon Graphics, Inc.
  9.  *
  10.  * RESTRICTED RIGHTS LEGEND:
  11.  * Use, duplication or disclosure by the Government is subject to restrictions
  12.  * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13.  * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14.  * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15.  * rights reserved under the Copyright Laws of the United States.
  16.  */
  17.  
  18.  
  19. #include <aux.h>
  20. #include <auxPrivate.h>
  21.  
  22.  
  23. /**************************************************************************
  24.  *    auxXErrorHandler() - X error handler routine
  25.  **************************************************************************/
  26.  
  27. int
  28. auxXErrorHandler( Display *display, XErrorEvent *event )
  29. {
  30.     const int     bufSize = 80;
  31.     char          buf[bufSize];
  32.  
  33.     printf( "\n   Received X error ...\n" );
  34.     printf( "\terror_code   : %d\n", event->error_code );
  35.     printf( "\trequest_code : %d\n", event->request_code );
  36.     printf( "\tminor_code   : %d\n\n", event->minor_code );
  37.     XGetErrorText( display, event->error_code, buf, bufSize );
  38.     printf( "\tError text : '%s'\n\n", buf );
  39. }
  40.  
  41.  
  42. /**************************************************************************
  43.  *    auxPrintVisualInfo() - Retrieve information from X visual
  44.  **************************************************************************/
  45.  
  46. static const char*
  47. className( int class )
  48. {
  49.     static char      *classes[] = {
  50.         "StaticGray",
  51.         "GrayScale",
  52.         "StaticColor",
  53.         "PseudoColor",
  54.         "TrueColor",
  55.         "DirectColor",
  56.     };
  57.  
  58.     if ( class < ZERO || class > FIVE )
  59.         return "unknown";
  60.     else
  61.         return classes[class];
  62. }
  63.  
  64. GLvoid
  65. auxPrintVisualInfo( XVisualInfo *glxVisual )
  66. {
  67.     int        tmp;
  68.  
  69.     printf("   X Visual Information ...\n\n" );
  70.     printf("\tvisualid : 0x%x\n", glxVisual->visualid );
  71.     printf("\tclass    : %s\n\n", className( glxVisual->class ) );
  72.  
  73. #define TrueFalse(x)  ( x ? "True" : "False" )
  74.  
  75.     glXGetConfig(auxState.display, glxVisual, GLX_USE_GL, &tmp);
  76.     printf( "\tSupport GL ( GLX_USE_GL )  : %s\n", TrueFalse(tmp) );
  77.  
  78.     glXGetConfig(auxState.display, glxVisual, GLX_LEVEL, &tmp);
  79.     printf( "\tFramebuffer ( GLX_LEVEL ) : %s\n\n",
  80.         tmp < ZERO ? "Underlay" : tmp > ZERO ? "Overlay"  : "Normal" );
  81.  
  82.     glXGetConfig(auxState.display, glxVisual, GLX_BUFFER_SIZE, &tmp);
  83.     printf( "\tFramebuffer depth ( GLX_BUFFER_SIZE )     : %d\n", tmp );
  84.  
  85.     glXGetConfig(auxState.display, glxVisual, GLX_DOUBLEBUFFER, &tmp);
  86.     printf( "\tDoublebuffer ( GLX_DOUBLEBUFFER )         : %s\n",
  87.         TrueFalse(tmp) );
  88.  
  89.     glXGetConfig(auxState.display, glxVisual, GLX_DEPTH_SIZE, &tmp);
  90.     printf( "\tDepth buffer depth ( GLX_DEPTH_SIZE )     : %d\n", tmp );
  91.  
  92.     glXGetConfig(auxState.display, glxVisual, GLX_STENCIL_SIZE, &tmp);
  93.     printf( "\tStencil buffer depth ( GLX_STENCIL_SIZE ) : %d\n", tmp );
  94.  
  95.     glXGetConfig(auxState.display, glxVisual, GLX_STEREO, &tmp);
  96.     printf( "\tStereo Buffer ( GLX_STEREO )              : %s\n",
  97.         TrueFalse(tmp) );
  98.  
  99.     glXGetConfig(auxState.display, glxVisual, GLX_AUX_BUFFERS, &tmp);
  100.     printf( "\tAuxillary Buffers ( GLX_AUX_BUFFERS )     : %d\n\n", tmp );
  101.  
  102.     glXGetConfig(auxState.display, glxVisual, GLX_RGBA, &tmp);
  103.     printf( "\tColor mode ( GLX_RGBA )       : %s\n", tmp ? "RGBA" : "Index" );
  104.  
  105.     glXGetConfig(auxState.display, glxVisual, GLX_RED_SIZE, &tmp);
  106.     printf( "\tRed Bits ( GLX_RED_SIZE )     : %d\n", tmp );
  107.  
  108.     glXGetConfig(auxState.display, glxVisual, GLX_GREEN_SIZE, &tmp);
  109.     printf( "\tGreen Bits ( GLX_GREEN_SIZE ) : %d\n", tmp );
  110.  
  111.     glXGetConfig(auxState.display, glxVisual, GLX_BLUE_SIZE, &tmp);
  112.     printf( "\tBlue Bits ( GLX_BLUE_SIZE )   : %d\n", tmp );
  113.  
  114.     glXGetConfig(auxState.display, glxVisual, GLX_ALPHA_SIZE, &tmp);
  115.     printf( "\tAlpha Bits ( GLX_ALPHA_SIZE ) : %d\n\n", tmp );
  116.  
  117.     glXGetConfig(auxState.display, glxVisual, GLX_ACCUM_RED_SIZE, &tmp);
  118.     printf( "\tRed Accumulation Bits ( GLX_ACCUM_RED_SIZE )     : %d\n", tmp );
  119.  
  120.     glXGetConfig(auxState.display, glxVisual, GLX_ACCUM_GREEN_SIZE, &tmp);
  121.     printf( "\tGreen Accumulation Bits ( GLX_ACCUM_GREEN_SIZE ) : %d\n", tmp );
  122.  
  123.     glXGetConfig(auxState.display, glxVisual, GLX_ACCUM_BLUE_SIZE, &tmp);
  124.     printf( "\tBlue Accumulation Bits ( GLX_ACCUM_BLUE_SIZE )   : %d\n", tmp );
  125.  
  126.     glXGetConfig(auxState.display, glxVisual, GLX_ACCUM_ALPHA_SIZE, &tmp);
  127.     printf( "\tAlpha Accumulation Bits ( GLX_ACCUM_ALPHA_SIZE ) : %d\n\n", tmp );
  128. }
  129.  
  130.  
  131. /**************************************************************************
  132.  *    auxPrintAttributeList() - print out attribList
  133.  **************************************************************************/
  134.  
  135. GLvoid
  136. auxPrintAttributeList( int *list )
  137. {
  138.     GLint         i;
  139.  
  140.     static char   *glxTokenName[] = {
  141.         "None",
  142.         "GLX_USE_GL",
  143.         "GLX_BUFFER_SIZE",
  144.         "GLX_LEVEL",
  145.         "GLX_RGBA",
  146.         "GLX_DOUBLEBUFFER",
  147.         "GLX_STEREO",
  148.         "GLX_AUX_BUFFERS",
  149.         "GLX_RED_SIZE",
  150.         "GLX_GREEN_SIZE",
  151.         "GLX_BLUE_SIZE",
  152.         "GLX_ALPHA_SIZE",
  153.         "GLX_DEPTH_SIZE",
  154.         "GLX_STENCIL_SIZE",
  155.         "GLX_ACCUM_RED_SIZE",
  156.         "GLX_ACCUM_GREEN_SIZE",
  157.         "GLX_ACCUM_BLUE_SIZE",
  158.         "GLX_ACCUM_ALPHA_SIZE"
  159.     };
  160.  
  161.     printf( "\n   Requested Attributes :\n" );
  162.  
  163.     for ( i = 0; list[i] != None; i++ )
  164.         switch( list[i] ) {
  165.  
  166.             case GLX_USE_GL :
  167.             case GLX_RGBA :
  168.             case GLX_STEREO :
  169.             case GLX_DOUBLEBUFFER :
  170.                 printf( "\t%s,\n", glxTokenName[list[i]] );
  171.                 break;
  172.  
  173.             case GLX_BUFFER_SIZE :
  174.             case GLX_LEVEL :
  175.             case GLX_AUX_BUFFERS :
  176.             case GLX_RED_SIZE :
  177.             case GLX_GREEN_SIZE :
  178.             case GLX_BLUE_SIZE :
  179.             case GLX_ALPHA_SIZE :
  180.             case GLX_DEPTH_SIZE :
  181.             case GLX_STENCIL_SIZE :
  182.             case GLX_ACCUM_RED_SIZE :
  183.             case GLX_ACCUM_GREEN_SIZE :
  184.             case GLX_ACCUM_BLUE_SIZE :
  185.             case GLX_ACCUM_ALPHA_SIZE :
  186.                 printf( "\t%s = %d,\n", glxTokenName[list[i]], list[i+1] );
  187.                 i++;
  188.                 break;
  189.         }
  190.     printf( "\tNone\n\n" );
  191. }
  192.